const statusMap = {
  success: { text: '已通过', cls: 'result--success' },
  warning: { text: '请关注', cls: 'result--warning' },
  error: { text: '未通过', cls: 'result--error' },
  info: { text: '提示', cls: 'result--info' }
};

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },

  properties: {
    status: {
      type: String,
      value: 'info'
    },
    title: {
      type: String,
      value: ''
    },
    description: {
      type: String,
      value: ''
    },
    score: {
      type: Number,
      value: null
    },
    meta: {
      type: String,
      value: ''
    },
    primaryActionText: {
      type: String,
      value: ''
    },
    secondaryActionText: {
      type: String,
      value: ''
    },
    extraText: {
      type: String,
      value: ''
    }
  },

  data: {
    statusClass: 'result--info',
    statusText: '提示'
  },

  lifetimes: {
    attached() {
      this.updateStatus();
    }
  },

  observers: {
    status() {
      this.updateStatus();
    }
  },

  methods: {
    updateStatus() {
      const statusInfo = statusMap[this.properties.status] || statusMap.info;
      this.setData({
        statusClass: statusInfo.cls,
        statusText: statusInfo.text
      });
    },

    onPrimary() {
      this.triggerEvent('primary');
    },

    onSecondary() {
      this.triggerEvent('secondary');
    }
  }
});
